/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bea.cliente.gui.builders;

import bea.cliente.core.GuiManagerState;
import bea.cliente.gui.controllers.LoginScreenController;
import bea.cliente.gui.styles.FontsStyles;
import bea.cliente.gui.styles.PanelStyles;
import bea.cliente.gui.styles.TextFieldStyles;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.builder.EffectBuilder;
import de.lessvoid.nifty.builder.LayerBuilder;
import de.lessvoid.nifty.builder.PanelBuilder;
import de.lessvoid.nifty.builder.ScreenBuilder;
import de.lessvoid.nifty.builder.TextBuilder;
import de.lessvoid.nifty.controls.button.builder.ButtonBuilder;
import de.lessvoid.nifty.controls.textfield.builder.TextFieldBuilder;
import de.lessvoid.nifty.screen.Screen;

/**
 *
 * @author ivan
 */
public class LoginScreenBuilder {

    public static final String BG_IMAGE = "Interface/images/loginBackground.jpg";

    public static Screen build(Nifty nifty) {
        Screen loginScreen = new ScreenBuilder(GuiManagerState.LOGIN_SCR) {

            {
                controller(new LoginScreenController());
                // camada de fundo "background"
                layer(new LayerBuilder("background") {

                    {
                        // imagem de fundo da tela de login
                        backgroundImage(BG_IMAGE);
                    }
                });
                // layer do formulario de login
                layer(new LayerBuilder("formLayer") {

                    {
                        childLayoutCenter();
                        // painel principal do fundo do formulario
                        panel(new PanelBuilder() {

                            {
                                style(PanelStyles.BLACK_STYLE);
                                height("150");
                                width(percentage(100));
                                alignCenter();
                                valignBottom();
                                childLayoutHorizontal();
                                visibleToMouse(true);

                                // painel do formulario
                                panel(new PanelBuilder() {

                                    {
                                        width("250");
                                        height(percentage(100));
                                        childLayoutVertical();
                                        valignCenter();
                                        alignRight();

                                        // painel que contem os campos de texto do formulario
                                        panel(new PanelBuilder() {

                                            {
                                                childLayoutHorizontal();
                                                height(percentage(80));
                                                width(percentage(100));

                                                // painel container dos labels do formulario
                                                panel(new PanelBuilder() {

                                                    {
                                                        childLayoutVertical();
                                                        height(percentage(100));
                                                        width(percentage(40));

                                                        // painel container do label "Login"
                                                        panel(new PanelBuilder() {

                                                            {
                                                                childLayoutCenter();
                                                                height(percentage(50));
                                                                width(percentage(80));
                                                                text(new TextBuilder() {

                                                                    {
                                                                        style(FontsStyles.GENERAL_WHITE_TEXT_16);
                                                                        text("Login: ");
                                                                        backgroundColor("#FFF0");
                                                                        alignRight();
                                                                        valignCenter();
                                                                    }
                                                                });
                                                            }
                                                        });

                                                        // painel container do label "Password"
                                                        panel(new PanelBuilder() {

                                                            {
                                                                childLayoutCenter();
                                                                height(percentage(50));
                                                                width(percentage(80));
                                                                text(new TextBuilder() {

                                                                    {
                                                                        style(FontsStyles.GENERAL_WHITE_TEXT_16);
                                                                        text("Password: ");
                                                                        backgroundColor("#FFF0");
                                                                        alignRight();
                                                                        valignCenter();
                                                                    }
                                                                });
                                                            }
                                                        });
                                                    }
                                                }); // final do containers dos labels "Login" e "Password"

                                                // painel container dos inputs
                                                panel(new PanelBuilder() {

                                                    {
                                                        childLayoutVertical();
                                                        height(percentage(100));
                                                        width(percentage(60));

                                                        // panel container do input "Login"
                                                        panel(new PanelBuilder() {

                                                            {
                                                                childLayoutCenter();
                                                                height(percentage(50));
                                                                control(new TextFieldBuilder("txtLogin") {

                                                                    {
                                                                        style(TextFieldStyles.NIFTY_STYLE);
                                                                        width(percentage(90));
                                                                        valignCenter();
                                                                    }
                                                                });
                                                            }
                                                        });// final do container do input "Login"

                                                        // panel container do input "Password"
                                                        panel(new PanelBuilder() {

                                                            {
                                                                childLayoutCenter();
                                                                height(percentage(50));
                                                                control(new TextFieldBuilder("txtPassword") {

                                                                    {
                                                                        //style(TextFieldStyles.BLACK_STYLE);
                                                                        width(percentage(90));
                                                                        valignCenter();
                                                                        passwordChar('*');
                                                                    }
                                                                });
                                                            }
                                                        });// final do container do input "Password"
                                                    }
                                                });// final do painel de container dos inputs
                                            }
                                        }); // final do container dos campos de texto

                                        // container dos botoes "Enter" e "Exit"
                                        panel(new PanelBuilder() {

                                            {
                                                childLayoutHorizontal();
                                                height(percentage(20));
                                                width(percentage(100));
                                                valignCenter();
                                                alignCenter();

                                                // container do botao "Enter"
                                                panel(new PanelBuilder() {

                                                    {
                                                        childLayoutCenter();
                                                        height(percentage(100));
                                                        width(percentage(50));
                                                        control(new ButtonBuilder("enterAction", "Enter") {

                                                            {
                                                                valignCenter();
                                                                alignCenter();
                                                                interactOnClick("onEnterButtonAction()");
                                                            }
                                                        });
                                                    }
                                                });// final do container do botao "Enter"

                                                // container do botao "Exit"
                                                panel(new PanelBuilder() {

                                                    {
                                                        childLayoutCenter();
                                                        height(percentage(100));
                                                        width(percentage(50));
                                                        control(new ButtonBuilder("exitAction", "Exit") {

                                                            {
                                                                valignCenter();
                                                                alignCenter();
                                                                interactOnClick("onExitAction()");
                                                            }
                                                        });
                                                    }
                                                });// final do container do botao "Exit"
                                            }
                                        }); // final do container do botao "Enter" e "Exit"
                                    }
                                });// final do container do formulario

                                // container dos botoes de opcoes
                                panel(new PanelBuilder() {

                                    {
                                        childLayoutVertical();
                                        height(percentage(100));
                                        width(percentage(100));
                                        padding("20px,0px,20px,100px");

                                        // container do botao de opcoes graficas
                                        panel(new PanelBuilder() {

                                            {
                                                childLayoutCenter();
                                                height(percentage(50));
                                                width(percentage(100));
                                                control(new ButtonBuilder("graphicsButton", "Graphics") {

                                                    {
                                                        alignLeft();
                                                        valignCenter();
                                                        interactOnClick("buildGraphicsOptionsWindow()");
                                                    }
                                                });
                                            }
                                        });// final do container do botao de opcoes graficas

                                        // container do botao de opcoes de audio
                                        panel(new PanelBuilder() {

                                            {
                                                childLayoutCenter();
                                                height(percentage(50));
                                                width(percentage(100));
                                                control(new ButtonBuilder("audioButton", "Audio") {

                                                    {
                                                        alignLeft();
                                                        valignCenter();
                                                        interactOnClick("buildAudioOptionsWindow()");
                                                    }
                                                });
                                            }
                                        });// final do container do botao de opcoes de audio
                                    }
                                }); // final do container dos botoes de opcoes "graphics" e "audio"
                                

                        //efeito de entrada da layer "bottom"
                        onStartScreenEffect(new EffectBuilder("move") {

                            {
                                effectParameter("mode", "in");
                                effectParameter("direction", "bottom");
                                effectParameter("length", "1000");
                                effectParameter("inherit", "true");
                                effectParameter("startDelay", "0");
                            }
                        });
                        
                         //efeito de entrada da layer "bottom"
                        onEndScreenEffect(new EffectBuilder("move") {

                            {
                                effectParameter("mode", "out");
                                effectParameter("direction", "bottom");
                                effectParameter("length", "1000");
                                effectParameter("inherit", "true");
                                effectParameter("startDelay", "0");
                            }
                        });
                        
                            }
                        }); // final do painel de fundo do formulario
                    }
                });// final da camada do formulario

            }
        }.build(nifty);
        return loginScreen;
    }
}